<template>
  <div>
    <Modal
      :value="modalState"
      :loading="loading"
      @on-ok="handleSubmit"
      @on-cancel="cancel"
      width="35%">
      <Form
        ref="refundModal"
        :model="row"
        :rules="ruleInline"
        style="width: 100%"
        :label-width="50">
        <div style="margin-left: 35px; margin-top: 30px">
          <div style="margin-bottom: 15px">
            <Icon type="md-checkmark-circle" size="30" color="#00cc33" />
            <span style="font-size: 16px; font-weight: bold; margin-left: 20px">退款客户备注信息</span>
          </div>
          <FormItem prop="remarks" style="width: 500px">
            <Input v-model="row.remarks" type="textarea" :rows="4" placeholder="请输入退款客户备注信息" />
          </FormItem>
        </div>
      </Form>
    </Modal>
  </div>
</template>
<script>
import {
  mapActions,
  mapState
} from 'vuex'
export default {
  name: 'RefundModal',
  props: {
    row: null
  },
  data () {
    return {
      title: '',
      loading: true,
      ruleInline: {
        // name: [
        //   { required: true, message: '姓名不能为空', trigger: 'blur' }
        // ],
        // tel: [
        //   { required: true, message: '手机号不能为空', trigger: 'blur' }
        // ]
      }
    }
  },
  updated () {
    this.title = '退款客户备注信息'
  },
  computed: {
    ...mapState({
      // row: state => state.taskList.row,
      modalState: state => state.modal.refundModalState
    })
  },
  methods: {
    ...mapActions(['updateCustomerDrawerState', 'updateRefundModalState']),
    changeLoading () {
      this.loading = false
      this.$nextTick(() => {
        this.loading = true
      })
    },
    handleSubmit () {
      this.$refs.refundModal.validate((valid) => {
        if (!valid) {
          return this.changeLoading()
        }
        this.$emit('refund-valid', {
          id: this.row.id,
          remarks: this.row.remarks
        })
        this.$refs['refundModal'].resetFields()
      })
    },
    cancel () {
      this.updateRefundModalState(false)
      this.updateCustomerDrawerState(true)
    }
  }
}
</script>
